package cn.richard.demo.tax.web;

import java.io.Serializable;

public class BaseResult implements Serializable{
	private static final long serialVersionUID = 1L;
	
	// 几个预设返回码
	public final static String SUCC_CODE = "0"; // 业务受理成功
	public final static String FAIL_CODE = "1"; // 业务受理失败

	private boolean success; // 业务是否受理成功
	private Object data; // 携带的业务数据，大部分情况下 success==true 才会带
	private String code; // 返回码，success==true 时，code==0
	private String msg; // 错误附加信息
	
	private BaseResult() {}
	
	public static BaseResult succ() {
		BaseResult rs = new BaseResult();
		rs.setSuccess(true);
		rs.setCode(SUCC_CODE);
		return rs;
	}
	public static BaseResult succData(Object data) {
		BaseResult rs = BaseResult.succ();
		rs.setData(data);
		return rs;
	}
	
	public static BaseResult fail() {
		BaseResult rs = new BaseResult();
		rs.setSuccess(false);
		rs.setCode(FAIL_CODE);
		return rs;
	}
	public static BaseResult failMsg(String msg) {
		BaseResult rs = BaseResult.fail();
		rs.setMsg(msg);
		return rs;
	}

	
	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
}
